import http from '../utils/http'
import { host } from '@/config'

export default {
  getHistory(params) {
    return http({
      url: `${host}/history`,
      method: 'POST',
      data: params
    })
  },

  searchUser({ searchKey }) {
    return http({
      url: `${host}/chat/search-user`,
      method: 'post',
      data: {
        searchKey: searchKey
      }
    })
  },

  getNewFriend({ user_id }) {
    return http({
      url: `${host}/chat/getNewFirentNotice`,
      method: 'post',
      data: {
        user_id: user_id
      }
    })
  },

  getFriendList({ user_id }) {
    return http({
      url: `${host}/chat/getFriendList`,
      method: 'post',
      data: {
        user_id: user_id
      }
    })
  },

  createRoom({ userIds }) {
    return http({
      url: `${host}/chat/createRoom`,
      method: 'post',
      data: {
        userIds: userIds.join(',')
      }
    })
  },

  getRoomList() {
    return http({
      url: `${host}/chat/getRoomList`,
      method: 'post'
    })
  },

  getRoomUserList({ roomId }) {
    return http({
      url: `${host}/chat/getRoomUserList`,
      method: 'post',
      data: {roomId}
    })
  },

  getChatList({ user_id }) {
    return http({
      url: `${host}/chat2`,
      method: 'post',
      data: {user_id}
    })
  }
}
